import os


def renameFiles(path):
    file_list = list([])
    for file in os.listdir(path):
        file_list.append(file)
    # print(len(file_list))

    len_file_list = len(file_list)

    for i in range(len_file_list):
        file = str(file_list[i])
        print(file)
        if file.endswith(".gif"):
            os.rename(os.path.join(path, file), os.path.join(path, str(i) + ".gif"))
        elif file.endswith(".jpg"):
            os.rename(os.path.join(path, file), os.path.join(path, str(i) + ".jpg"))
        elif file.endswith(".png"):
            os.rename(os.path.join(path, file), os.path.join(path, str(i) + ".png"))
        else:
            print("格式无法识别，自动跳过！")


if __name__ == '__main__':
    # renameFiles('F:\\Documents\\Tencent Files\\594328762\\Image\\Group')
    renameFiles('F:\\Documents\\Tencent Files\\594328762\\Image\\Group\\Image1')
